using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class CodingSystemAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public CodingSystemAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.User;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"99zzz or L","ACR","ART","AS4","AS4E","ATC","C4","C5","CAS","CD2","CDCA","CDCM","CDS","CE","CLP","CPTM","CST","CVX","DCL","DCM","DQL","E","E5","E6","E7","ENZC","FDDC","FDDX","FDK","HB","HCPCS","HHC","HI","HL7nnnn","HPC","I10","I10P","I9","I9C","IBT","IC2","ICDO","ICS","ICSD","ISOnnnn","IUPP","IUPC","JC8","LB","LN","MCD","MCR","MDDX","MEDC","MEDR","MEDX","MGPI","MVX","NDA","NDC","NIC","NPI","OHA","POS","RC","SDM","SNM","SNM3","SNT","UC","UMD","UML","UPC","UPIN","W1","W2","W4","WC"};
						validVersionCodes[HL7Version.v25] = new string[]{"99zzz or L","ACR","ART","ANS+","AS4","AS4E","ATC","C4","C5","CAS","CD2","CDCA","CDCM","CDS","CE","CLP","CPTM","CST","CVX","DCM","E","E5","E6","E7","ENZC","FDDC","FDDX","FDK","HB","HCPCS","HCPT","HHC","HI","HL7nnnn","HOT","HPC","I10","I10P","I9","I9C","IBT","IBTnnnn","IC2","ICD10AM","ICD10CA","ICDO","ICS","ICSD","ISOnnnn","ISO+","IUPP","IUPC","JC8","JC10","JJ1017","LB","LN","MCD","MCR","MDDX","MEDC","MEDR","MEDX","MGPI","MVX","NDA","NDC","NIC","NPI","NUBC","OHA","POS","RC","SDM","SNM","SNM3","SNT","UC","UMD","UML","UPC","UPIN","USPS","W1","W2","W4","WC"};
						validVersionCodes[HL7Version.v251] = new string[]{"99zzz or L","ACR","ART","ANS+","AS4","AS4E","ATC","C4","C5","CAS","CD2","CDCA","CDCM","CDS","CE","CLP","CPTM","CST","CVX","DCM","E","E5","E6","E7","ENZC","FDDC","FDDX","FDK","HB","HCPCS","HCPT","HHC","HI","HL7nnnn","HOT","HPC","I10","I10P","I9","I9C","IBT","IBTnnnn","IC2","ICD10AM","ICD10CA","ICDO","ICS","ICSD","ISOnnnn","ISO+","IUPP","IUPC","JC8","JC10","JJ1017","LB","LN","MCD","MCR","MDDX","MEDC","MEDR","MEDX","MGPI","MVX","NDA","NDC","NIC","NPI","NUBC","OHA","POS","RC","SDM","SNM","SNM3","SNT","UC","UMD","UML","UPC","UPIN","USPS","W1","W2","W4","WC"};
						validVersionCodes[HL7Version.v26] = new string[]{"99zzz or L","ACR","ALPHAID2006","ALPHAID2007","ALPHAID2008","ART","ANS+","AS4","AS4E","ATC","C4","C5","CAS","CCC","CD2","CDCA","CDCM","CDS","CE (obsolete)","CLP","CPTM","CST","CVX","DCM","E","E5","E6","E7","ENZC","FDDC","FDDX","FDK","GDRG2004","GDRG2005","GDRG2006","GDRG2007","GDRG2008","GMDC2004","GMDC2005","GMDC2006","GMDC2007","GMDC2008","HB","HCPCS","HCPT","HHC","HI","HL7nnnn","HOT","HPC","I10","I10P","I9","I9C","I9CDX","I9CP","IBT","IBTnnnn","I10G2004","I10G2005","I10G2006","ICD10GM2007","ICD10GM2008","ICD10AM","ICD10CA","ICDO","ICS","ICSD","ISOnnnn","ISO+","ITIS","IUPP","IUPC","JC8","JC10","JJ1017","LB","LN","MCD","MCR","MDC","MDDX","MEDC","MEDR","MEDX","MGPI","MVX","NCPDPnnnnsss","NDA","NDC","NIC","NPI","NUBC","OHA","O301","O3012004","O3012005","O3012006","OPS2007","OPS2008","POS","RC","SCT","SCT2","SDM","SNM","SNM3","SNT","UB04FL14","UB04FL15","UB04FL17","UC","UCUM","UMD","UML","UPC","UPIN","USPS","W1","W2","W4","WC","X12DEnnnn"};
						validVersionCodes[HL7Version.v27] = new string[]{"L","HPC","ACR","ALPHAID2006","ALPHAID2007","ALPHAID2008","ALPHAID2009","ALPHAID2010","ALPHAID2011","ART","ANS+","AS4","AS4E","ATC","C4","CAPECC","CAS","CCC","CD2","CDCA","CDCEDACUITY","CDCM","CDCOBS","CDCPHINVS","CDCREC","CDS","CE (obsolete)","CLP","CPTM","CST","CVX","DCM","E","E5","E6","E7","ENZC","EPASRS","FDAUNII","FDDC","FDDX","FDK","FIPS5_2","FIPS6_4","GDRG2004","GDRG2005","GDRG2006","GDRG2007","GDRG2008","GDRG2009","GMDC2004","GMDC2005","GMDC2006","GMDC2007","GMDC2008","GMDC2009","HB","HCPCS","HCPT","HHC","HI","HL7nnnn","HOT","99zzz","I10","I10G2004","I10G2005","I10G2006","I10P","I9","I9C","I9CDX","I9CP","IBT","IBTnnnn","IC2","ICD10GM2007","ICD10GM2008","ICD10GM2009","ICD10GM2010","ICD10GM2011","ICD10AM","ICD10CA","ICDO","ICDO2","ICDO3","ICS","ICSD","ISOnnnn (deprecated)","ISO","ISO3166_1","ISO3166_2","ISO4217","ISO639","ITIS","IUPP","IUPC","JC8","JC10","JJ1017","LB","LN","MCD","MCR","MDC","MDDX","MEDC","MEDR","MEDX","MGPI","MVX","NAICS","NCPDPnnnnsss","NDA","NDC","NDFRT","NIC","NIP001","NIP002","NIP004","NIP007","NIP008","NIP009","NIP010","NND","NPI","NUBC","NULLFL","OHA","O301","O3012004","O3012005","O3012006","OPS2007","OPS2008","OPS2009","OPS2010","OPS2011","PHINQUESTION","PLR","PLT","POS","RC","RXNORM","SCT","SCT2","SDM","SIC","SNM","SNM3","SNT","SOC","UB04FL14","UB04FL15","UB04FL17","UB04FL31","UB04FL35","UB04FL39","UC","UCUM","UMD","UML","UPC","UPIN","USPS","W1","W2","W4","WC","X12Dennnn"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"Local general code (where z is an alphanumeric character)","American College of Radiology finding codes","WHO Adverse Reaction Terms","ASTM E1238/ E1467 Universal","AS4 Neurophysiology Codes","American Type Culture Collection","CPT-4","CPT-5","Chemical abstract codes","CDT-2 Codes","CDC Analyte Codes","CDC Methods/Instruments Codes","CDC Surveillance","CEN ECG diagnostic codes","CLIP","CPT Modifier Code","COSTART","CDC Vaccine Codes","DICOM Class Label","DICOM modality codes","DICOM Query Label","EUCLIDES","Euclides  quantity codes","Euclides Lab method codes","Euclides Lab equipment codes","Enzyme Codes","First DataBank Drug Codes","First DataBank Diagnostic Codes","FDA K10","HIBCC","HCFA Common Procedure Coding System","Home Health Care","Health Outcomes","HL7 Defined Codes where nnnn is the HL7 table number","HCFA Procedure Codes (HCPCS)","ICD-10","ICD-10  Procedure Codes","ICD9","ICD-9CM","ISBT","ICHPPC-2","International Classification of Diseases for Oncology","ICCS","International Classification of Sleep Disorders","ISO Defined Codes where nnnn is the ISO table number","IUPAC/IFCC Property Codes","IUPAC/IFCC Component Codes","Japanese Chemistry","Local billing code","Logical Observation Identifier Names and Codes (LOINC(r))","Medicaid","Medicare","Medispan Diagnostic Codes","Medical Economics Drug Codes","Medical Dictionary for Drug Regulatory Affairs (MEDDRA)","Medical Economics Diagnostic Codes","Medispan GPI","CDC Vaccine Manufacturer Codes","NANDA","National drug codes","Nursing Interventions Classification","National Provider Identifier","Omaha System","POS Codes","Read Classification","SNOMED- DICOM Microglossary","Systemized Nomenclature of Medicine (SNOMED)","SNOMED International","SNOMED topology codes (anatomic sites)","UCDS","MDNS","Unified Medical Language","Universal Product Code","UPIN","WHO record # drug codes (6 digit)","WHO record # drug codes (8 digit)","WHO record # code with ASTM extension","WHO ATC"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Local general code (where z is an alphanumeric character)","American College of Radiology finding codes","WHO Adverse Reaction Terms","HL7 set of units of measure","ASTM E1238/ E1467 Universal","AS4 Neurophysiology Codes","American Type Culture Collection","CPT-4","CPT-5","Chemical abstract codes","CDT-2 Codes","CDC Analyte Codes","CDC Methods/Instruments Codes","CDC Surveillance","CEN ECG diagnostic codes","CLIP","CPT Modifier Code","COSTART","CDC Vaccine Codes","DICOM Controlled Terminology","EUCLIDES","Euclides  quantity codes","Euclides Lab method codes","Euclides Lab equipment codes","Enzyme Codes","First DataBank Drug Codes","First DataBank Diagnostic Codes","FDA K10","HIBCC","CMS (formerly HCFA)  Common Procedure Coding System","Health Care Provider Taxonomy","Home Health Care","Health Outcomes","HL7 Defined Codes where nnnn is the HL7 table number","Japanese Nationwide Medicine Code","CMS (formerly HCFA )Procedure Codes (HCPCS)","ICD-10","ICD-10  Procedure Codes","ICD9","ICD-9CM","ISBT","ISBT 128 codes where nnnn  specifies a specific table within ISBT 128.","ICHPPC-2","ICD-10 Australian modification","ICD-10 Canada","International Classification of Diseases for Oncology","ICCS","International Classification of Sleep Disorders","ISO Defined Codes where nnnn is the ISO table number","ISO 2955.83 (units of measure) with HL7 extensions","IUPAC/IFCC Property Codes","IUPAC/IFCC Component Codes","Japanese Chemistry","JLAC/JSLM, nationwide laboratory code","Japanese Image Examination Cache","Local billing code","Logical Observation Identifier Names and Codes (LOINC®)","Medicaid","Medicare","Medispan Diagnostic Codes","Medical Economics Drug Codes","Medical Dictionary for Drug Regulatory Affairs (MEDDRA)","Medical Economics Diagnostic Codes","Medispan GPI","CDC Vaccine Manufacturer Codes","NANDA","National drug codes","Nursing Interventions Classification","National Provider Identifier","National Uniform Billing Committee Code","Omaha System","POS Codes","Read Classification","SNOMED- DICOM Microglossary","Systemized Nomenclature of Medicine (SNOMED)","SNOMED International","SNOMED topology codes (anatomic sites)","UCDS","MDNS","Unified Medical Language","Universal Product Code","UPIN","United States Postal Service","WHO record # drug codes (6 digit)","WHO record # drug codes (8 digit)","WHO record # code with ASTM extension","WHO ATC"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Local general code (where z is an alphanumeric character)","American College of Radiology finding codes","WHO Adverse Reaction Terms","HL7 set of units of measure","ASTM E1238/ E1467 Universal","AS4 Neurophysiology Codes","American Type Culture Collection","CPT-4","CPT-5","Chemical abstract codes","CDT-2 Codes","CDC Analyte Codes","CDC Methods/Instruments Codes","CDC Surveillance","CEN ECG diagnostic codes","CLIP","CPT Modifier Code","COSTART","CDC Vaccine Codes","DICOM Controlled Terminology","EUCLIDES","Euclides  quantity codes","Euclides Lab method codes","Euclides Lab equipment codes","Enzyme Codes","First DataBank Drug Codes","First DataBank Diagnostic Codes","FDA K10","HIBCC","CMS (formerly HCFA)  Common Procedure Coding System","Health Care Provider Taxonomy","Home Health Care","Health Outcomes","HL7 Defined Codes where nnnn is the HL7 table number","Japanese Nationwide Medicine Code","CMS (formerly HCFA )Procedure Codes (HCPCS)","ICD-10","ICD-10  Procedure Codes","ICD9","ICD-9CM","ISBT","ISBT 128 codes where nnnn  specifies a specific table within ISBT 128.","ICHPPC-2","ICD-10 Australian modification","ICD-10 Canada","International Classification of Diseases for Oncology","ICCS","International Classification of Sleep Disorders","ISO Defined Codes where nnnn is the ISO table number","ISO 2955.83 (units of measure) with HL7 extensions","IUPAC/IFCC Property Codes","IUPAC/IFCC Component Codes","Japanese Chemistry","JLAC/JSLM, nationwide laboratory code","Japanese Image Examination Cache","Local billing code","Logical Observation Identifier Names and Codes (LOINCÂ®)","Medicaid","Medicare","Medispan Diagnostic Codes","Medical Economics Drug Codes","Medical Dictionary for Drug Regulatory Affairs (MEDDRA)","Medical Economics Diagnostic Codes","Medispan GPI","CDC Vaccine Manufacturer Codes","NANDA","National drug codes","Nursing Interventions Classification","National Provider Identifier","National Uniform Billing Committee Code","Omaha System","POS Codes","Read Classification","SNOMED- DICOM Microglossary","Systemized Nomenclature of Medicine (SNOMED)","SNOMED International","SNOMED topology codes (anatomic sites)","UCDS","MDNS","Unified Medical Language","Universal Product Code","UPIN","United States Postal Service","WHO record # drug codes (6 digit)","WHO record # drug codes (8 digit)","WHO record # code with ASTM extension","WHO ATC"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Local general code (where z is an alphanumeric character)","American College of Radiology finding codes","German Alpha-ID v2006","German Alpha-ID v2007","German Alpha-ID v2008","WHO Adverse Reaction Terms","HL7 set of units of measure","ASTM E1238/ E1467 Universal","AS4 Neurophysiology Codes","American Type Culture Collection","CPT-4","CPT-5","Chemical abstract codes","Clinical Care Classification system","CDT-2 Codes","CDC Analyte Codes","CDC Methods/Instruments Codes","CDC Surveillance","CEN ECG diagnostic codes","CLIP","CPT Modifier Code","COSTART","CDC Vaccine Codes","DICOM Controlled Terminology","EUCLIDES","Euclides  quantity codes","Euclides Lab method codes","Euclides Lab equipment codes","Enzyme Codes","First DataBank Drug Codes","First DataBank Diagnostic Codes","FDA K10","G-DRG German DRG Codes v2004","G-DRG German DRG Codes v2005","G-DRG German DRG Codes v2006","G-DRG German DRG Codes v2007","G-DRG German DRG Codes v2008","German Major Diagnostic Codes v2004","German Major Diagnostic Codes v2005","German Major Diagnostic Codes v2006","German Major Diagnostic Codes v2007","German Major Diagnostic Codes v2008","HIBCC","CMS (formerly HCFA)  Common Procedure Coding System","Health Care Provider Taxonomy","Home Health Care","Health Outcomes","HL7 Defined Codes where nnnn is the HL7 table number","Japanese Nationwide Medicine Code","CMS (formerly HCFA )Procedure Codes (HCPCS)","ICD-10","ICD-10  Procedure Codes","ICD9","ICD-9CM","ICD-9CM Diagnosis codes","ICD-9CM Procedure codes","ISBT","ISBT 128 codes where nnnn  specifies a specific table within ISBT 128.","ICD 10 Germany v2004","ICD 10 Germany v2005","ICD 10 Germany v2006","ICD 10 Germany v2007","ICD 10 Germany v2008","ICD-10 Australian modification","ICD-10 Canada","International Classification of Diseases for Oncology","ICCS","International Classification of Sleep Disorders","ISO Defined Codes where nnnn is the ISO table number","ISO 2955.83 (units of measure) with HL7 extensions","Integrated Taxonomic Information System","IUPAC/IFCC Property Codes","IUPAC/IFCC Component Codes","Japanese Chemistry","JLAC/JSLM, nationwide laboratory code","Japanese Image Examination Cache","Local billing code","Logical Observation Identifier Names and Codes (LOINCÂ®)","Medicaid","Medicare","Medical Device Communication","Medispan Diagnostic Codes","Medical Economics Drug Codes","Medical Dictionary for Drug Regulatory Affairs (MEDDRA)","Medical Economics Diagnostic Codes","Medispan GPI","CDC Vaccine Manufacturer Codes","NCPDP code list for data element nnnn [as used in segment sss]","NANDA","National drug codes","Nursing Interventions Classification","National Provider Identifier","National Uniform Billing Committee Code","Omaha System","German Procedure Codes","OPS Germany v2004","OPS Germany v2005","OPS Germany v2006","OPS Germany v2007","OPS Germany v2008","POS Codes","Read Classification","SNOMED Clinical Terms","SNOMED Clinical Terms alphanumeric codes","SNOMED- DICOM Microglossary","Systemized Nomenclature of Medicine (SNOMED)","SNOMED International","SNOMED topology codes (anatomic sites)","Priority (Type) of Visit","Point of Origin","Patient Discharge Status","UCDS","UCUM code set for units of measure(from Regenstrief)","MDNS","Unified Medical Language","Universal Product Code","UPIN","United States Postal Service","WHO record # drug codes (6 digit)","WHO record # drug codes (8 digit)","WHO record # code with ASTM extension","WHO ATC","ASC X12 Code List nnnn"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Local general code","CMS (formerly HCFA )Procedure Codes (HCPCS)","American College of Radiology finding codes","German Alpha-ID v2006","German Alpha-ID v2007","German Alpha-ID v2008","German Alpha-ID v2009","German Alpha-ID v2010","German Alpha-ID v2011","WHO Adverse Reaction Terms","HL7 set of units of measure","ASTM E1238/ E1467 Universal","AS4 Neurophysiology Codes","American Type Culture Collection","CPT-4","College of American Pathologists Electronic Cancer Checklist","Chemical abstract codes","Clinical Care Classification system","CDT-2 Codes","CDC Analyte Codes","CDC Emergency Department Acuity","CDC Methods/Instruments Codes","CDC BioSense RT observations (Census) - CDC","CDC PHIN Vocabulary Coding System","Race & Ethnicity - CDC","CDC Surveillance","CEN ECG diagnostic codes","CLIP","CPT Modifier Code","COSTART","CDC Vaccine Codes","DICOM Controlled Terminology","EUCLIDES","Euclides  quantity codes","Euclides Lab method codes","Euclides Lab equipment codes","Enzyme Codes","EPA SRS","Unique Ingredient Identifier (UNII)","First DataBank Drug Codes","First DataBank Diagnostic Codes","FDA K10","FIPS 5-2 (State)","FIPS 6-4 (County)","G-DRG German DRG Codes v2004","G-DRG German DRG Codes v2005","G-DRG German DRG Codes v2006","G-DRG German DRG Codes v2007","G-DRG German DRG Codes v2008","G-DRG German DRG Codes v2009","German Major Diagnostic Codes v2004","German Major Diagnostic Codes v2005","German Major Diagnostic Codes v2006","German Major Diagnostic Codes v2007","German Major Diagnostic Codes v2008","German Major Diagnostic Codes v2009","HIBCC","CMS (formerly HCFA)  Common Procedure Coding System","Health Care Provider Taxonomy","Home Health Care","Health Outcomes","HL7 Defined Codes where nnnn is the HL7 table number","Japanese Nationwide Medicine Code","Local general code where z is an alphanumeric character","ICD-10","ICD 10 Germany 2004","ICD 10 Germany 2005","ICD 10 Germany 2006","ICD-10  Procedure Codes","ICD9","ICD-9CM","ICD-9CM Diagnosis codes","ICD-9CM Procedure codes","ISBT","ISBT 128 codes where nnnn  specifies a specific table within ISBT 128.","ICHPPC-2","ICD 10 Germany v2007","ICD 10 Germany v2008","ICD 10 Germany v2009","ICD 10 Germany v2010","ICD 10 Germany v2011","ICD-10 Australian modification","ICD-10 Canada","International Classification of Diseases for Oncology","International Classification of Disease for Oncology Second Edition","International Classification of Disease for Oncology Third Edition","ICCS","International Classification of Sleep Disorders","ISO Defined Codes where nnnn is the ISO table number","ISO 2955.83 (units of measure) with HL7 extensions","ISO 3166-1 Country Codes","ISO 3166-2 Country subdivisions","ISO4217 Currency Codes","ISO 639 Language","Integrated Taxonomic Information System","IUPAC/IFCC Property Codes","IUPAC/IFCC Component Codes","Japanese Chemistry","JLAC/JSLM, nationwide laboratory code","Japanese Image Examination Cache","Local billing code","Logical Observation Identifier Names and Codes (LOINCÂ®)","Medicaid","Medicare","Medical Device Communication","Medispan Diagnostic Codes","Medical Economics Drug Codes","Medical Dictionary for Drug Regulatory Affairs (MEDDRA)","Medical Economics Diagnostic Codes","Medispan GPI","CDC Vaccine Manufacturer Codes","Industry (NAICS)","NCPDP code list for data element nnnn [as used in segment sss]","NANDA","National drug codes","NDF-RT (Drug Classification)","Nursing Interventions Classification","Source of Information (Immunization)","Substance refusal reason","Vaccination - Contraindications, Precautions, and Immunities","Vaccinated at location (facility)","Vaccine purchased with (Type of funding)","Reported adverse event previously","VAERS Report type","Notifiable Event (Disease/Condition) Code List","National Provider Identifier","National Uniform Billing Committee","Null Flavor","Omaha System","German Procedure Codes","OPS Germany v2004","OPS Germany v2005","OPS Germany v2006","OPS Germany v2007","OPS Germany v2008","OPS Germany v2009","OPS Germany v2010","OPS Germany v2011","CDC Public Health Information Network (PHIN) Question","CDC PHLIP Lab result codes that are not covered in SNOMED at the time of this implementation","CDC PHLIP Lab test codes, where LOINC concept is too broad or not yet available, especially as needed for ordering and or lab to lab reporting )","POS Codes","Read Classification","RxNorm","SNOMED Clinical Terms","SNOMED Clinical Terms alphanumeric codes","SNOMED- DICOM Microglossary","Industry (SIC)","Systemized Nomenclature of Medicine (SNOMED)","SNOMED International","SNOMED topology codes (anatomic sites)","Occupation (SOC 2000)","Priority (Type) of Visit","Point of Origin","Patient Discharge Status","Occurrence Code","Occurrence Span","Value Code","UCDS","UCUM code set for units of measure(from Regenstrief)","MDNS","Unified Medical Language","Universal Product Code","UPIN","United States Postal Service","WHO record # drug codes (6 digit)","WHO record # drug codes (8 digit)","WHO record # code with ASTM extension","WHO ATC","ASC X12 Code List nnnn"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
